package com.unitTest;

import static org.junit.Assert.*;

import org.joda.time.DateTime;
import org.junit.Test;

import com.acmetelecom.DurationCalculator;

public class DurationCalculatorTest {

	/* start:			2011-1-1 18:58:00:000
	 * end:				2011 1-1 18:59:00:000
	 * peakSeconds:		60
	 * offPeakSeconds:	0
	 */
	@Test
	public void testDurationCalculator1() {
		DateTime start = new DateTime(2011,1,1, 18, 58, 00, 000);
		DateTime end = new DateTime(2011,1,1, 18, 59, 00, 000);
		DurationCalculator dc = new DurationCalculator(start,end);
		assertEquals(60,dc.getPeakSeconds());		
		assertEquals(0,dc.getOffPeakSeconds());
	}
	
	/* start:			2011-1-1 18:58:00:000
	 * end:				2011 1-1 19:01:00:000
	 * peakSeconds:		120
	 * offPeakSeconds:	60
	 */
	@Test
	public void testDurationCalculator2() {
		DateTime start = new DateTime(2011,1,1, 18, 58, 00, 000);
		DateTime end = new DateTime(2011,1,1, 19, 01, 00, 000);
		DurationCalculator dc = new DurationCalculator(start,end);
		assertEquals(120,dc.getPeakSeconds());
		assertEquals(60,dc.getOffPeakSeconds());
	}
	
	/* start:			2011-1-1 18:58:00:000
	 * end:				2011 1-2 19:01:00:000
	 * peakSeconds:		43320
	 * offPeakSeconds:	43260
	 */
	@Test
	public void testDurationCalculator3() {
		DateTime start = new DateTime(2011,1,1, 18, 58, 00, 000);
		DateTime end = new DateTime(2011,1,2, 19, 01, 00, 000);
		DurationCalculator dc = new DurationCalculator(start,end);
		assertEquals(43320,dc.getPeakSeconds());
		assertEquals(43260,dc.getOffPeakSeconds());
	}
	
	/* start:			2011-1-1 18:59:58:999
	 * end:				2011 1-1 19:00:00:001
	 * peakSeconds:		2
	 * offPeakSeconds:	1
	 */
	@Test
	public void testDurationCalculator4() {
		DateTime start = new DateTime(2011,1,1, 18, 59, 58, 002);
		DateTime end = new DateTime(2011,1,1, 19, 00, 00, 003);
		DurationCalculator dc = new DurationCalculator(start,end);
		assertEquals(2,dc.getPeakSeconds());
		assertEquals(1,dc.getOffPeakSeconds());
	}
}
